package com.piece.blog.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.util.Date;

@Data
@NoArgsConstructor
@Document(collection = "blog_question")
@ApiModel(value = "题库表: blog_question")
@CompoundIndexes({
        @CompoundIndex(name = "index_question", def = "{'question_id':1,'group':1}")
})
public class BlogQuestion implements Serializable {

    @Id
    @ApiModelProperty(value = "主键")
    private String questionId;

    @Field("group")
    @ApiModelProperty(value = "所属")
    private String group;

    @Field("title")
    @ApiModelProperty(value = "题目")
    private String title;

    @Field("type")
    @ApiModelProperty(value = "题目类型", notes = "checkbox, radio, textarea")
    private String type;

    @Field("options")
    @ApiModelProperty(value = "选项")
    private String options;

    @Transient
    @ApiModelProperty(value = "选项值")
    private String[] optionItem;

    @Field("answer")
    @ApiModelProperty(value = "答案")
    private String answer;

    @Field("points")
    @ApiModelProperty(value = "分值")
    private int points;

    @Field("position")
    @ApiModelProperty(value = "序号")
    private int position;

    @Field("status")
    @ApiModelProperty(value = "有效状态", notes = "0=有效, 1=无效")
    private String status;

    @Field("create_by")
    @ApiModelProperty(value = "创建人")
    private String createBy;

    @Field("create_time")
    @ApiModelProperty(value = "创建时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date createTime;
}
